#ifndef TRIE_H
#define	TRIE_H

#include "TrieNode.h"

template <class T>
class Trie
{
public:
    
    Trie()
    {
        this->root_ = 0;
    }

    ~Trie()
    {
        if (this->root_)
            delete this->root_;
    }
    
    TrieNode<T>* getRoot()
    {
        return this->root_;
    }

    void addWord(std::string word, T& value)
    {
        if(! this->root_)
            this->root_ = new TrieNode<T>(word.at(0));
        root_->addWord(word, 0, value);
    }

    T* search(std::string word)
    {
        T* found = 0;
        if (this->root_)
            found = this->root_->search(word, 0);
        return found;
    }
    
private:
    TrieNode<T>* root_;
};

#endif	/* TRIE_H */

